<template>
  <div>
    <minder-editor
      :import-json="importJson"
      :progress-enable="true"
      :tag-enable="true"
      :sequence-enable="true"
      :tags="tags"
      :disabled="false"
      :distinct-tags="tags"
      :height="500"
      :tag-edit-check="test"
      :minder-url="minderUrl"
      :priority-disable-check="test"
      @afterMount="afterMount()"
      :default-mold="3"
      @moldChange="handleMoldChange"
      @save="save"/>
  </div>
</template>

<script>
import Vue from 'vue'
import minderEditor from "../components/plugin";
Vue.use(minderEditor) //开发测试

export default {
  name: "dev-test",
  data() {
    return {
      minderUrl: { upload: 'https://jsonplaceholder.typicode.com/posts/', download: '///'},
      importJson: {
        "root": {
          "data": {
            "text": "百度产品",
            "image": "https://www.baidu.com/img/bd_logo1.png?where=super",
            "imageTitle": "imageTitle",
            "imageSize": { "width": 270, "height": 129 }
          },
          "children": [
            { "data": { "text": "新闻" } },
            { "data": { "text": "网页", "priority": 1 } },
            { "data": { "text": "贴吧", "priority": 2 } },
            { "data": { "text": "知道", "priority": 2 } },
            { "data": { "text": "音乐", "priority": 3 } },
            { "data": { "text": "图片", "priority": 3 } },
            { "data": { "text": "视频", "priority": 3 } },
            { "data": { "text": "地图", "priority": 3 } },
            { "data": { "text": "百科", "priority": 3 } },
            { "data": { "text": "更多", "hyperlink": "http://www.baidu.com/more", "hyperlinkTitle": "<a>124</a>" } }
          ]
        }
      },
      tags:  ['模块1','用例','用例1','用例2','用例3','用例4','用例5','用例6','用例7','用例8']
    }
  },
  mounted() {
    sessionStorage.setItem("minderUrl",JSON.stringify(this.minderUrl))
  },

  methods: {
    save(data) {
      console.log(data);
    },
    test() {
      // return () => {
        return true
      // };
    },
    handleMoldChange(a) {
      console.log(a);
    },
    afterMount() {
      minder.on('selectionchange ', function (env) {
        let selectNodes = env.minder.getSelectedNodes();
        if (selectNodes) {
          console.log('selectionchange');
          console.log(selectNodes);
          // selectNodes.forEach((node) => {
          //   markChangeNode(node);
          // })
        }
      })
      // minder.on('contentchange', function (env) {
      //   console.log('contentchange');
      //   console.log(env);
      // });
    },
  }
}
</script>

<style scoped>

</style>
